﻿$TelnetService = "TlntSvr"

Stop-Service $TelnetService -Force

# see http://technet.microsoft.com/en-us/library/cc754102(v=WS.10).aspx
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1

$servicePrivs = sc.exe qprivs $TelnetService | 
                    ForEach-Object {
                        if ($_ -match ".* : (.*)") {
                            $Matches[1].Trim()
                        }
                    }

$servicePrivs = $servicePrivs + "SeTcbPrivilege"
sc.exe privs $TelnetService ($servicePrivs -join '/')
sc.exe config $TelnetService obj=LocalSystem

Set-Service -Name $TelnetService -StartupType Automatic

Start-Service $TelnetService
